package com.zhl.study.configuration;

import com.zhl.study.service.chainResponsibility.IHandler;
import com.zhl.study.service.chainResponsibility.ProductChainFactory;
import com.zhl.study.service.chainResponsibility.ProductChainSpringFactory;
import com.zhl.study.vo.Product;
import com.zhl.study.vo.Student;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import java.util.List;

/**
 * @description TODO
 * @Author: z156940l@outlook.com
 * @className MyConfig
 * @Date: 2024/12/26 22:05
 */
@Configuration
public class MyConfig {

    @Bean
    @Primary // 标记为主要的 Bean
    public ProductChainSpringFactory<Product, Boolean> productChainSpringFactory(List<IHandler<Product, Boolean>> handlers){
        return new ProductChainSpringFactory<Product, Boolean>(handlers);
    }

//    @Bean
//    public ProductChainSpringFactory<Student, Boolean> cChainChainSpringFactory(List<IHandler<Student, Boolean>> handlers){
//        return new ProductChainSpringFactory<Student, Boolean>(handlers);
//    }

    @Bean
    public ProductChainFactory productChainFactory(List<IHandler> handlerList){
        return new ProductChainFactory(handlerList);
    }
}
